/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entities1;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author takamflore
 */
@Entity
@Table(catalog = "meteoCalDB", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Invited.findAll", query = "SELECT i FROM Invited i"),
    @NamedQuery(name = "Invited.findByIdEvent", query = "SELECT i FROM Invited i WHERE i.id = :idEvent"),
    @NamedQuery(name = "Invited.findByIdUser", query = "SELECT i FROM Invited i WHERE i.id = :idUser"),
    @NamedQuery(name = "Invited.findByDate", query = "SELECT i FROM Invited i WHERE i.date = :date")})
public class Invited implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer id;
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @JoinColumn(name = "IdUser", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Users user;
    @JoinColumn(name = "idEvent", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Event event;

    public Invited() {
    }

    public Invited(Integer id) {
        this.id = id;
    }
    
    public Invited(int idEvent,int idUser) {
        this.event.setId(idEvent);
        this.user.setId(idUser);
    }
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Invited)) {
            return false;
        }
        Invited other = (Invited) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Invited[ id=" + id + " ]";
    }
    
}
